#include <stdio.h>
#include <event.h>
#include <time.h>

struct event ev;
struct timeval tv;

void time_fn(int fd, short event, void *arg)
{
    printf("timer function\n");
    event_add(&ev, &tv);// add into struct event instance
}

int main(int argc, char const *argv[])
{
    struct event_base *base = event_init();// init libevent 
    tv.tv_sec = 1;
    tv.tv_usec = 0; // 1 second interval then call time_fn

    event_new(&ev, -1, 0, time_fn, NULL);

    event_add(&ev, &tv);

    event_base_dispatch(base);


    return 0;
}
